package com.liaogui.consumer.controller;

import com.liaogui.common.entity.userinfo.UserInfoEntity;
import com.liaogui.common.service.userinfo.UserInfoService;
import com.liaogui.common.utils.PageUtils;
import com.liaogui.common.utils.R;

import org.apache.dubbo.config.annotation.Reference;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 
 *
 * @author Àî°Â¹é
 * @email liaogui1023@163.com
 * @date 2021-12-02 17:14:19
 */
@RestController
@RequestMapping("myblog/userinfo")
public class UserInfoController {
    @Reference
    private UserInfoService userInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("myblog:userinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("myblog:userinfo:info")
    public R info(@PathVariable("id") String id){
		UserInfoEntity userInfo = userInfoService.getById(id);

        return R.ok().put("userInfo", userInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("myblog:userinfo:save")
    public R save(@RequestBody UserInfoEntity userInfo){
		userInfoService.save(userInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("myblog:userinfo:update")
    public R update(@RequestBody UserInfoEntity userInfo){
		userInfoService.updateById(userInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("myblog:userinfo:delete")
    public R delete(@RequestBody String[] ids){
		userInfoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
